package com.css.fxfzysx.modules.cztDataMange.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.css.fxfzysx.base.response.RestResponse;
import com.css.fxfzysx.constants.FxfzConstants;
import com.css.fxfzysx.modules.cztDataMange.entity.*;
import com.css.fxfzysx.modules.cztDataMange.repository.BacInformationRepository;
import com.css.fxfzysx.modules.cztDataMange.repository.BasicLibraryRepository;
import com.css.fxfzysx.modules.cztDataMange.service.BacInformationService;
import com.css.fxfzysx.modules.cztDataMange.service.BasicLibraryService;
import com.css.fxfzysx.modules.cztDataMange.vo.BasicLibraryVo;
import com.css.fxfzysx.modules.lifeline.service.LifelineFoundationLibraryService;
import com.css.fxfzysx.modules.vabStructure.entity.CztBuildingMatrixEntity;
import com.css.fxfzysx.modules.vabStructure.param.CustomVulnerabilityParam;
import com.css.fxfzysx.modules.vabStructure.param.MatchingParam;
import com.css.fxfzysx.modules.vabStructure.param.PageParam;
import com.css.fxfzysx.modules.vabStructure.repository.CustomVulnerabilityRepository;
import com.css.fxfzysx.modules.vabStructure.repository.SvAnalysisRepository;
import com.css.fxfzysx.modules.vabStructure.service.impl.CustomVulnerabilityServiceImpl;
import com.css.fxfzysx.modules.vabStructure.service.impl.SvAnalysisServiceImpl;
import com.css.fxfzysx.modules.vabStructure.vo.GenerateVulnerabilityMatrixVo;
import com.css.fxfzysx.util.CreateGson;
import com.css.fxfzysx.util.PlatformObjectUtils;
import com.css.fxfzysx.util.PlatformPageUtils;
import com.css.fxfzysx.web.PlatformSessionContext;
import com.css.fxfzysx.zcpt.sys.entity.SUser;
import com.css.fxfzysx.zcpt.sys.service.SUserService;
import com.css.fxfzysx.zcpt.sys.service.SysAreaService;
import com.css.fxfzysx.zcpt.sys.service.SysRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
@Slf4j
public class BasicLibraryServiceImpl implements BasicLibraryService {

    @Autowired
    private BasicLibraryRepository basicLibraryRepository;

    @Autowired
    private SvAnalysisRepository svAnalysisRepository;

    @Autowired
    private SysRoleService roleService;

    @Autowired
    private SvAnalysisServiceImpl svAnalysisService;

    @Autowired
    private CustomVulnerabilityRepository customVulnerabilityRepository;

    @Autowired
    private BacInformationService bacInformationService;

    @Autowired
    private BacInformationRepository bacInformationRepository;

    @Autowired
    private SUserService userService;

    @Autowired
    private SysAreaService areaService;

    @Autowired
    private LifelineFoundationLibraryService libraryService;

    @Override
    public RestResponse queryBasicLibrary(CustomVulnerabilityParam param, HttpServletRequest request) {
        try {
            int page = Integer.valueOf(request.getParameter(PlatformPageUtils.CUR_PAGE));
            int size = Integer.valueOf(request.getParameter(PlatformPageUtils.PAGE_SIZE));
            String user = userService.getSUser(PlatformSessionContext.getUserID());
            SUser sUser = CreateGson.createGson().fromJson(user, SUser.class);
            String province = areaService.getAreaNameByAreaId(sUser.getProvinceId());
            if(PlatformObjectUtils.isEmpty(param.getProvince())){
                param.setProvince(province);
            }
            Integer role = libraryService.getRole();
            return RestResponse.succeed(basicLibraryRepository.queryBasicLibrary(param, page, size,role,province));
        } catch (NumberFormatException e) {
            String message = "查看失败!";
            log.error(message, e);
            return RestResponse.fail(message);
        }
    }

    @Override
    public RestResponse removeBasicLibrary(String dataType, String id,String province) {
        try {
            String userID = PlatformSessionContext.getUserID();
            String role = roleService.getRoleByUserId(userID);
            List<Map> roleMaps = JSONObject.parseArray(role, Map.class);
            ArrayList<String> roleList = new ArrayList<>();
            for (Map roleMap : roleMaps) {
                String roleCode = (String) roleMap.get("roleCode");
                roleList.add(roleCode);
            }
            if (!roleList.contains(FxfzConstants.CZT_COUN_GL_ROLE)) {
                return RestResponse.fail("失败,暂无权限!");
            }
            if (dataType.equals(FxfzConstants.CZT_JZWYSX_INFO)) {
                basicLibraryRepository.moveBvById(id,province);
            }
            if (dataType.equals(FxfzConstants.CZT_GLDZ_INFO)) {
                basicLibraryRepository.movePvById(id);
            }
            if (dataType.equals(FxfzConstants.CZT_SCYSX_INFO)) {
                svAnalysisRepository.moveBasicLibraryById(id, "0");
            }
            return RestResponse.succeed("成功!");
        } catch (Exception e) {
            String message = "失败!";
            log.error(message, e);
            return RestResponse.fail(message);
        }
    }

    @Override
    public RestResponse getMatrix(String dataType, String id,String province) {
        HashMap<String, Object> resultMap = new HashMap<>();
        try {
            //矩阵数据
            List<GenerateVulnerabilityMatrixVo> matrixData = getMatrixData(dataType, id,province);
            resultMap.put("matrix", matrixData);
            //概率地震
            if (dataType.equals(FxfzConstants.CZT_GLDZ_INFO)) {
                List<CpvResultEntity> dataList = bacInformationService.getCpvResultEntityByCpviId(id);
                resultMap.put("curve", dataList);
            }
            //易损性信息
            if (dataType.equals(FxfzConstants.CZT_JZWYSX_INFO)) {
                //先查出来是矩阵数据还是曲线数据
                CbvInfoEntity entity = customVulnerabilityRepository.getBasicLibraryById(id,province);
                if (entity.getCurveOrMatrix() == 0) {
                    List<CbvInfoCurveValueEntity> dataList = customVulnerabilityRepository.getCureByCbviId(id);
                    resultMap.put("curve", dataList);
                }
            }
            return RestResponse.succeed(resultMap);
        } catch (Exception e) {
            String message = "查看失败!";
            log.error(message, e);
            return RestResponse.fail(message);
        }
    }

    /**
     * 获取矩阵数据
     *
     * @param dataType
     * @param id
     * @return
     */
    private List<GenerateVulnerabilityMatrixVo> getMatrixData(String dataType, String id,String province) {
        List<GenerateVulnerabilityMatrixVo> dataList = null;
        //生成的易损性数据
        if (dataType.equals(FxfzConstants.CZT_SCYSX_INFO)) {
            CztBuildingMatrixEntity entity = svAnalysisRepository.getBuildingMatrixById(id);
            String spilt = SvAnalysisServiceImpl.spilt(entity.getDataSourcesIds());
            String[] intensityArr = {"6度", "7度", "8度", "9度", "10度"};
            //震害数据矩阵
            if (entity.getMatrixType() == 1) {
                dataList = svAnalysisService.getDataList(spilt, intensityArr);
            }
            // 2 预测数据矩阵  3 筛选数据矩阵
            if (entity.getMatrixType() == 2 || entity.getMatrixType() == 3) {
                dataList = svAnalysisService.getPredictiveData(spilt, intensityArr, entity.getMatrixType());
            }
        }

        if (dataType.equals(FxfzConstants.CZT_JZWYSX_INFO)) {
            //先查出来是矩阵数据还是曲线数据
            CbvInfoEntity entity = customVulnerabilityRepository.getBasicLibraryById(id,province);
            if (entity.getCurveOrMatrix() == 1) {
                List<CbvInfoMatrixValueEntity> matrixList = svAnalysisRepository.getInfoMatrixById(id);
                ArrayList<GenerateVulnerabilityMatrixVo> matrixDataList = new ArrayList<>();
                if (matrixList != null) {
                    matrixList.forEach(ma -> {
                        GenerateVulnerabilityMatrixVo entity1 = new GenerateVulnerabilityMatrixVo();
                        entity1.setDamage("基本完好");
                        entity1.setIntensity(ma.getIntensity());
                        entity1.setRate(ma.getBasicallyIntact().toString() + "%");
                        matrixDataList.add(entity1);
                        GenerateVulnerabilityMatrixVo entity2 = new GenerateVulnerabilityMatrixVo();
                        entity2.setDamage("轻微破坏");
                        entity2.setIntensity(ma.getIntensity());
                        entity2.setRate(ma.getMinorDamage().toString() + "%");
                        matrixDataList.add(entity2);
                        GenerateVulnerabilityMatrixVo entity3 = new GenerateVulnerabilityMatrixVo();
                        entity3.setDamage("中等破坏");
                        entity3.setIntensity(ma.getIntensity());
                        entity3.setRate(ma.getModerateDamage().toString() + "%");
                        matrixDataList.add(entity3);
                        GenerateVulnerabilityMatrixVo entity4 = new GenerateVulnerabilityMatrixVo();
                        entity4.setDamage("严重破坏");
                        entity4.setIntensity(ma.getIntensity());
                        entity4.setRate(ma.getSeriousDamage().toString() + "%");
                        matrixDataList.add(entity4);
                        GenerateVulnerabilityMatrixVo entity5 = new GenerateVulnerabilityMatrixVo();
                        entity5.setDamage("倒塌");
                        entity5.setIntensity(ma.getIntensity());
                        entity5.setRate(ma.getCollapse().toString() + "%");
                        matrixDataList.add(entity5);
                    });
                }
                dataList = matrixDataList;
            }
        }
        return dataList;
    }

    @Override
    public void exportMatrix(HttpServletResponse response, String dataType, String id,String province) {
        List<GenerateVulnerabilityMatrixVo> matrixData = getMatrixData(dataType, id,province);
        svAnalysisService.exportMatrixUtil(response, matrixData);
    }

    @Override
    public List<BasicLibraryVo> getByRegion(MatchingParam param) {
        List<CbvInfoEntity> basicLibraryList = customVulnerabilityRepository.queryBasicLibraryData(param);

        ArrayList<BasicLibraryVo> resultList = new ArrayList<>();

        basicLibraryList.forEach(it -> {
            it.setOrderField(it.getProvince() + it.getCity() + it.getCounty() + it.getStructureType() + (PlatformObjectUtils.isNotEmpty(it.getStructureType1()) ? it.getStructureType1() : "") + it.getFortification());
        });

        Map<String, List<CbvInfoEntity>> collect = basicLibraryList.stream().collect(Collectors.groupingBy(CbvInfoEntity::getOrderField));

        collect.forEach((k, v) -> {
            BasicLibraryVo vo = new BasicLibraryVo();
            v.forEach(it -> {
                //生成的易损性数据
                if (it.getDataType().equals(FxfzConstants.CZT_SCYSX_INFO)) {
                    List<GenerateVulnerabilityMatrixVo> dataList = null;
                    CztBuildingMatrixEntity entity = svAnalysisRepository.getBuildingMatrixById(it.getPId());
                    String spilt = SvAnalysisServiceImpl.spilt(entity.getDataSourcesIds());
                    String[] intensityArr = {"6度", "7度", "8度", "9度", "10度"};
                    //震害数据矩阵
                    if (entity.getMatrixType() == 1) {
                        dataList = svAnalysisService.getDataList(spilt, intensityArr);
                    }
                    // 2 预测数据矩阵  3 筛选数据矩阵
                    if (entity.getMatrixType() == 2 || entity.getMatrixType() == 3) {
                        dataList = svAnalysisService.getPredictiveData(spilt, intensityArr, entity.getMatrixType());
                    }
                    ArrayList<BasicLibraryVo.stateValue> valueList = turningCurve(dataList);
                    vo.setStructureType(it.getStructureType());
                    if (PlatformObjectUtils.isNotEmpty(it.getStructureType1())) {
                        vo.setStructureType1(it.getStructureType1());
                    }
                    vo.setDefenseSituation(it.getFortification());
                    vo.setValueList(valueList);
                    resultList.add(vo);
                }
                //概率地震
                if (it.getDataType().equals(FxfzConstants.CZT_GLDZ_INFO)) {
                    CpvInfoEntity entity = bacInformationRepository.getCpviById(it.getPId());
                    ArrayList<BasicLibraryVo.stateValue> valueList = new ArrayList<>();
                    BasicLibraryVo.stateValue sd = new BasicLibraryVo.stateValue();
                    sd.setDestructiveState("轻微破坏");
                    sd.setMr(PlatformObjectUtils.isNotEmpty(entity.getMSd1())?entity.getMSd1():BigDecimal.valueOf(0.01));
                    sd.setBr(PlatformObjectUtils.isNotEmpty(entity.getPSd1())?entity.getPSd1():BigDecimal.valueOf(0.01));
                    valueList.add(sd);

                    BasicLibraryVo.stateValue md = new BasicLibraryVo.stateValue();
                    md.setDestructiveState("中等破坏");
                    md.setMr(PlatformObjectUtils.isNotEmpty(entity.getMMd1())?entity.getMSd1():BigDecimal.valueOf(0.01));
                    md.setBr(PlatformObjectUtils.isNotEmpty(entity.getPMd1())?entity.getPMd1():BigDecimal.valueOf(0.01));
                    valueList.add(md);

                    BasicLibraryVo.stateValue ed = new BasicLibraryVo.stateValue();
                    ed.setDestructiveState("严重破坏");
                    ed.setMr(PlatformObjectUtils.isNotEmpty(entity.getMEd1())?entity.getMEd1():BigDecimal.valueOf(0.01));
                    ed.setBr(PlatformObjectUtils.isNotEmpty(entity.getPEd1())?entity.getPEd1():BigDecimal.valueOf(0.01));
                    valueList.add(ed);

                    BasicLibraryVo.stateValue c = new BasicLibraryVo.stateValue();
                    c.setDestructiveState("倒塌");
                    c.setMr(PlatformObjectUtils.isNotEmpty(entity.getMCd1())?entity.getMCd1():BigDecimal.valueOf(0.01));
                    c.setBr(PlatformObjectUtils.isNotEmpty(entity.getPCd1())?entity.getPCd1():BigDecimal.valueOf(0.01));
                    valueList.add(c);

                    vo.setStructureType(entity.getStructureType0());
                    if (PlatformObjectUtils.isNotEmpty(entity.getStructureType1())) {
                        vo.setStructureType1(entity.getStructureType1());
                    }
                    vo.setDefenseSituation(entity.getFortification());
                    vo.setValueList(valueList);
                    resultList.add(vo);
                }
                //易损性信息
                if (it.getDataType().equals(FxfzConstants.CZT_JZWYSX_INFO)) {
                    CbvInfoEntity entity = customVulnerabilityRepository.getBasicLibraryById(it.getPId(),it.getProvince());
                    if (entity.getCurveOrMatrix() == 0) {
                        ArrayList<BasicLibraryVo.stateValue> valueList = new ArrayList<>();
                        BasicLibraryVo.stateValue sd = new BasicLibraryVo.stateValue();
                        sd.setDestructiveState("轻微破坏");
                        sd.setMr(entity.getSdMr());
                        sd.setBr(entity.getSdBr());
                        valueList.add(sd);

                        BasicLibraryVo.stateValue md = new BasicLibraryVo.stateValue();
                        md.setDestructiveState("中等破坏");
                        md.setMr(entity.getMdBr());
                        md.setBr(entity.getMdBr());
                        valueList.add(md);

                        BasicLibraryVo.stateValue ed = new BasicLibraryVo.stateValue();
                        ed.setDestructiveState("严重破坏");
                        ed.setMr(entity.getEdMr());
                        ed.setBr(entity.getEdBr());
                        valueList.add(ed);

                        BasicLibraryVo.stateValue c = new BasicLibraryVo.stateValue();
                        c.setDestructiveState("倒塌");
                        c.setMr(entity.getCollapseMr());
                        c.setBr(entity.getCollapseBr());
                        valueList.add(c);

                        vo.setStructureType(entity.getStructureType());
                        if (PlatformObjectUtils.isNotEmpty(entity.getStructureType1())) {
                            vo.setStructureType1(entity.getStructureType1());
                        }
                        vo.setDefenseSituation(entity.getFortification());
                        vo.setValueList(valueList);
                        resultList.add(vo);
                    } else {
                        List<CbvInfoMatrixValueEntity> matrixList = svAnalysisRepository.getInfoMatrixById(it.getPId());
                        ArrayList<GenerateVulnerabilityMatrixVo> matrixDataList = new ArrayList<>();
                        if (matrixList != null) {
                            matrixList.forEach(ma -> {
                                GenerateVulnerabilityMatrixVo entity1 = new GenerateVulnerabilityMatrixVo();
                                entity1.setDamage("基本完好");
                                entity1.setIntensity(ma.getIntensity());
                                entity1.setRate(ma.getBasicallyIntact().toString() + "%");
                                matrixDataList.add(entity1);
                                GenerateVulnerabilityMatrixVo entity2 = new GenerateVulnerabilityMatrixVo();
                                entity2.setDamage("轻微破坏");
                                entity2.setIntensity(ma.getIntensity());
                                entity2.setRate(ma.getMinorDamage().toString() + "%");
                                matrixDataList.add(entity2);
                                GenerateVulnerabilityMatrixVo entity3 = new GenerateVulnerabilityMatrixVo();
                                entity3.setDamage("中等破坏");
                                entity3.setIntensity(ma.getIntensity());
                                entity3.setRate(ma.getModerateDamage().toString() + "%");
                                matrixDataList.add(entity3);
                                GenerateVulnerabilityMatrixVo entity4 = new GenerateVulnerabilityMatrixVo();
                                entity4.setDamage("严重破坏");
                                entity4.setIntensity(ma.getIntensity());
                                entity4.setRate(ma.getSeriousDamage().toString() + "%");
                                matrixDataList.add(entity4);
                                GenerateVulnerabilityMatrixVo entity5 = new GenerateVulnerabilityMatrixVo();
                                entity5.setDamage("倒塌");
                                entity5.setIntensity(ma.getIntensity());
                                entity5.setRate(ma.getCollapse().toString() + "%");
                                matrixDataList.add(entity5);
                            });
                        }
                        ArrayList<BasicLibraryVo.stateValue> valueList = turningCurve(matrixDataList);
                        vo.setStructureType(it.getStructureType());
                        if (PlatformObjectUtils.isNotEmpty(it.getStructureType1())) {
                            vo.setStructureType1(it.getStructureType1());
                        }
                        vo.setDefenseSituation(it.getFortification());
                        vo.setValueList(valueList);
                        resultList.add(vo);
                    }
                }
            });
        });
        return resultList;
    }

    /**
     * 矩阵转曲线
     */
    private ArrayList<BasicLibraryVo.stateValue> turningCurve(List<GenerateVulnerabilityMatrixVo> matrix) {
        String ins = "基本完好,轻微破坏,中等破坏,严重破坏,倒塌";
        ArrayList<BasicLibraryVo.stateValue> stateValueList = new ArrayList<>();
        for (String in : ins.split(",")) {
            List<BigDecimal> xList = new ArrayList<>();
            ArrayList<BigDecimal> yList = new ArrayList<>();
            BasicLibraryVo.stateValue entity = new BasicLibraryVo.stateValue();
            matrix.forEach(it -> {
                if (in.equals(it.getDamage())) {
                    xList.add(CustomVulnerabilityServiceImpl.removalPercentage(it.getRate()));
                    switch (it.getIntensity()) {
                        case "6度":
                            yList.add(BigDecimal.valueOf(0.05));
                            break;
                        case "7度":
                            yList.add(BigDecimal.valueOf(0.1));
                            break;
                        case "8度":
                            yList.add(BigDecimal.valueOf(0.2));
                            break;
                        case "9度":
                            yList.add(BigDecimal.valueOf(0.4));
                            break;
                        case "10度":
                            yList.add(BigDecimal.valueOf(0.8));
                            break;
                    }
                }
            });
            HashMap<String, BigDecimal> mrdAndBrm = CustomVulnerabilityServiceImpl.getMrdAndBrm(xList, yList);
            entity.setDestructiveState(in);
            entity.setMr(mrdAndBrm.get("mrd"));
            entity.setBr(mrdAndBrm.get("brd"));
            stateValueList.add(entity);
        }
        return stateValueList;
    }

    @Override
    public HashMap<String, Object> page(PageParam param) {
        return basicLibraryRepository.page(param);
    }

    @Override
    public List<GenerateVulnerabilityMatrixVo> getByIdAndType(String dataType, String id,String province) {
        List<GenerateVulnerabilityMatrixVo> list = null;
        //矩阵数据
        list = getMatrixData(dataType, id,province);
        //概率地震
        if (dataType.equals(FxfzConstants.CZT_GLDZ_INFO)) {
            List<CpvResultEntity> dataList = bacInformationService.getCpvResultEntityByCpviId(id);
            list = getProcessData(dataList);
        }
        //易损性信息
        if (dataType.equals(FxfzConstants.CZT_JZWYSX_INFO)) {
            //先查出来是矩阵数据还是曲线数据
            CbvInfoEntity entity = customVulnerabilityRepository.getBasicLibraryById(id,province);
            if (entity.getCurveOrMatrix() == 0) {
                List<CbvInfoCurveValueEntity> dataList = customVulnerabilityRepository.getCureByCbviId(id);
                list = CustomVulnerabilityServiceImpl.getProcessData(dataList);
            }
        }
        return list;
    }

    public static List<GenerateVulnerabilityMatrixVo> getProcessData(List<CpvResultEntity> dataList) {

        ArrayList<GenerateVulnerabilityMatrixVo> resultList = new ArrayList<>();

        BigDecimal[] ims = {BigDecimal.valueOf(0.05), BigDecimal.valueOf(0.1), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.4), BigDecimal.valueOf(0.8)};

        for (BigDecimal im : ims) {
            String intensity = "";
            if (im.compareTo(BigDecimal.valueOf(0.05)) == 0) {
                intensity = "6度";
            }
            if (im.compareTo(BigDecimal.valueOf(0.1)) == 0) {
                intensity = "7度";
            }
            if (im.compareTo(BigDecimal.valueOf(0.2)) == 0) {
                intensity = "8度";
            }
            if (im.compareTo(BigDecimal.valueOf(0.4)) == 0) {
                intensity = "9度";
            }
            if (im.compareTo(BigDecimal.valueOf(0.8)) == 0) {
                intensity = "10度";
            }

            BigDecimal sd = BigDecimal.ZERO;
            BigDecimal md = BigDecimal.ZERO;
            BigDecimal ed = BigDecimal.ZERO;
            BigDecimal c = BigDecimal.ZERO;
            for (CpvResultEntity it : dataList) {
                if (it.getIm().compareTo(im) == 0) {
                    if (it.getBreakState().equals("SD")) {
                        sd = it.getFim();
                    }
                    if (it.getBreakState().equals("MD")) {
                        md = it.getFim();
                    }
                    if (it.getBreakState().equals("ED")) {
                        ed = it.getFim();
                    }
                    if (it.getBreakState().equals("CD")) {
                        c = it.getFim();
                    }
                }
            }
            GenerateVulnerabilityMatrixVo cVo = new GenerateVulnerabilityMatrixVo();
            cVo.setIntensity(intensity);
            cVo.setDamage("倒塌");
            cVo.setRate(c + "%");
            resultList.add(cVo);

            GenerateVulnerabilityMatrixVo edVo = new GenerateVulnerabilityMatrixVo();
            edVo.setIntensity(intensity);
            edVo.setDamage("严重破坏");
            BigDecimal ed1 = ed.subtract(c);
            edVo.setRate(ed1 + "%");
            resultList.add(edVo);

            GenerateVulnerabilityMatrixVo mdVo = new GenerateVulnerabilityMatrixVo();
            mdVo.setIntensity(intensity);
            mdVo.setDamage("中等破坏");
            BigDecimal md1 = md.subtract(ed);
            mdVo.setRate(md1+ "%");
            resultList.add(mdVo);

            GenerateVulnerabilityMatrixVo sdVo = new GenerateVulnerabilityMatrixVo();
            sdVo.setIntensity(intensity);
            sdVo.setDamage("轻微破坏");
            BigDecimal sd1 = sd.subtract(md);
            sdVo.setRate(sd1+ "%");
            resultList.add(sdVo);

            GenerateVulnerabilityMatrixVo basicallyIntactVo = new GenerateVulnerabilityMatrixVo();
            basicallyIntactVo.setIntensity(intensity);
            basicallyIntactVo.setDamage("基本完好");
            BigDecimal basicallyIntactValue = BigDecimal.valueOf(100).subtract(sd1).subtract(ed1).subtract(md1).subtract(c);
            basicallyIntactVo.setRate(basicallyIntactValue + "%");
            resultList.add(basicallyIntactVo);
        }
        return resultList;
    }
}
